{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=330
  Verdict: Accepted
}
uses SysUtils, Math;
 
const
	eps:double=1e-6;
 
type
	point=record
		x,y:longint;
		s:int64;
	end;
 
var
	i,n,kk,cc:longint;
	s1,s2,s3:int64;
	s,nm,sn:string;
	ca,cur:double;
	a:array[0..1010,1..2] of string;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(n);
ca:=0;
cc:=0;
for i:=1 to n do begin
	readln(S);
	kk:=pos(' ',s);
	nm:=copy(s,1,kk-1);
	delete(s,1,kk);  
	kk:=pos(' ',s);
	sn:=copy(s,1,kk-1);
	delete(s,1,kk);
	kk:=pos(' ',s);
	s1:=strtoint(copy(s,1,kk-1));
	delete(s,1,kk);
	kk:=pos(' ',s);
	s2:=strtoint(copy(s,1,kk-1));
	delete(s,1,kk);	
	kk:=pos(' ',s);
	if kk=0 then s3:=strtoint(s) else s3:=strtoint(copy(s,1,kk-1));
	cur:=(s1+s2+S3)/3;
	if abs(ca-cur)<eps then begin
		inc(cc);
		a[cc][1]:=nm;
		a[cc][2]:=sn;	
	end else 
	if cur-ca>eps then begin
		cc:=1;
		a[1][1]:=nm;
		a[1][2]:=sn;
		ca:=cur;
	end;
end;
for i:=1 to cc do
	writeln(a[i][1],' ',a[i][2]);
end.